<!--
 * @Author       : 郭庆红
 * @Date         : 2025-03-03 14:43:34
 * @LastEditors  : 郭庆红
 * @LastEditTime : 2025-03-17 15:12:35
 * @FilePath     : e:\project\zhlx-autoform-ui\src\components\form-designer\setting-panel\property-editor\defaultValue-editor.vue
 * @Description  : 
 * Copyright 2025 OBKoro1, All Rights Reserved. 
 * 2025-03-03 14:43:34
-->
<template>
  <template v-if="optionModel.selectType">
    <el-form-item label="默认值">
      <CommonSelect v-model="optionModel.defaultValue" :placeholder="optionModel.placeholder"
                   :multiple="optionModel.multiple" :clearable="optionModel.clearable"
                   :disabled="optionModel.disabled" @change="onOrganizeChange" :authorityList="optionModel.authorityList"
                   :choosePerson="optionModel.choosePerson" :isReturnData="optionModel.isReturnData"/>
    </el-form-item>
  </template>
  <template v-else-if="selectedWidget.type == 'select-unit'">
    <el-form-item label="默认值">
      <unitSelect
        ref="unitSelectRef"
        :placeholder="optionModel.placeholder"
        :disabled="optionModel.readonly"
        @input="onUserChange"
        :selectType="optionModel.selectType"
        :field="selectedWidget"
        v-model="optionModel.defaultValue"
      />
    </el-form-item>
  </template>
  <template v-else-if="selectedWidget.type == 'select-process'">
    <el-form-item label="默认值">
      <SelectProcess 
      :field="selectedWidget" 
      :options="selectedWidget.options"
      :disabled="optionModel.readonly"
      v-model="optionModel.defaultValue"></SelectProcess>
    </el-form-item>
  </template>
  <template v-else>
    <el-form-item v-if="!hasConfig('optionItems') && !visableRef.includes(selectedWidget.type)" label="默认值">
      <el-input type="text" v-model="optionModel.defaultValue"
                @input="emitDefaultValueChange"></el-input>
    </el-form-item>
  </template>
</template>

<script>
  import i18n from "@/utils/i18n"
  import propertyMixin from "@/components/form-designer/setting-panel/property-editor/propertyMixin"
  import CommonSelect from "@/components/ZHLX-Components/common/commonSelect/index2.vue";
  import unitSelect from "@/components/ZHLX-Components/ZHLX-unitSelect/index.vue";
  import SelectProcess from "@/components/ZHLX-Components/ZHLX-processSelect/index.vue";

  export default {
    name: "defaultValue-editor",
    mixins: [i18n, propertyMixin],
    components: { CommonSelect, unitSelect, SelectProcess },
    props: {
      designer: Object,
      selectedWidget: Object,
      optionModel: Object,
    },
    data(){
      return {
        visableRef:['file-list']  
      }
    },
    methods:{
      onOrganizeChange (val,list) {
        const dataList = this.optionModel.isReturnData ? list : val
        const value = this.optionModel.multiple ? dataList : dataList[0];
        this.emitFormModelChange(value);
        this.optionModel.defaultValue = value;
      },
      onUserChange(val, list) {
        this.emitFormModelChange(val)
        this.optionModel.defaultValue = val;
      },
    },
  }
</script>

<style scoped lang="scss">
.unit-select-container {
  height: 100%;
  :deep(.el-textarea__inner) {
    min-height: 24px !important;
  }
}
</style>
